﻿<UserControl x:Class="OI.Views.PrintView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Controls1="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" mc:Ignorable="d">

    <Grid x:Name="LayoutRoot" 
          Background="White"
		  Width="1100"
		  Height="850"
		  Margin="50">

        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" x:Name="TitleBlock" Style="{StaticResource PageTitle}" />

        <!--LEGEND-->
        <Border Grid.Row="1" Grid.Column="0" BorderThickness="2" BorderBrush="Gray" CornerRadius="2" Margin="0,0,4,0">
            <ItemsControl x:Name="Items" Grid.Column="0">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <RadioButton x:Name="selRB" GroupName="LegendItems">                        
                            <RadioButton.Template>
                                <ControlTemplate>
                                    <Grid Background="Transparent">

                                        <!--Selection Rectangle-->
                                        <Rectangle x:Name="SelectionVisualRect" Opacity="0" Width="240" VerticalAlignment="Top" HorizontalAlignment="Left" 
                                               Height="{Binding IconSize}" Fill="{StaticResource ThemeColorBrush}" IsHitTestVisible="False"/>

                                        <!--Item-->
                                        <StackPanel Orientation="Horizontal"  Margin="2"  VerticalAlignment="Top" HorizontalAlignment="Left">

                                            <!--Visibility checkbox-->
                                            <CheckBox Margin="0,4,0,0" IsChecked="{Binding IsVisible, Mode=TwoWay}" IsTabStop="False"
                                                  VerticalAlignment="Top" Height="{Binding IconSize}" IsEnabled="{Binding InRange}"/>

                                            <!--Non-Subclassed Item gets a single icon-->
                                            <Image Margin="6,0,0,0" Source="{Binding Icon}" VerticalAlignment="Top" Height="{Binding IconSize}" 
                                               Visibility="{Binding IsIconVisible}"/>

                                            <!--Not Visible-->
                                            <Image Source="../Images/not_visible.png" Margin="6,0,0,0" VerticalAlignment="Top" Height="{Binding IconSize}"
                                               Visibility="{Binding IsOutOfScaleVisible}" ToolTipService.ToolTip="Layer is out of scale range"/>

                                            <!--Subclassed Item is an expander of subitems-->
                                            <Controls1:Expander Margin="6,0,0,0" ExpandDirection="Down" IsExpanded="True" IsTabStop="False"
                                            HorizontalAlignment="Center" VerticalAlignment="Top" 
                                            Background="Transparent" Style="{StaticResource OIExpanderStyle}"
                                            Visibility="{Binding IsExpanderVisible}">
                                            </Controls1:Expander>

                                            <!--Header-->
                                            <TextBlock Margin="6,2,0,0" Height="{Binding IconSize}" Text="{Binding Label}" Style="{StaticResource LegendItems}" />
                                        </StackPanel>

                                        <!--Subclass Grid-->
                                        <Grid x:Name="SubclassGrid" Height="0" Margin="23,32,0,0">
                                            <ItemsControl x:Name="SubItems"
                                                      ItemsSource="{Binding Classes}">
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <StackPanel Orientation="Horizontal">
                                                            <Image Margin="6,0,0,0" Source="{Binding Icon}" VerticalAlignment="Top" Height="{Binding IconSize}" />
                                                            <TextBlock Margin="6,2,0,0" Height="{Binding IconSize}" Text="{Binding Label}" Style="{StaticResource LegendItems}" />
                                                        </StackPanel>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </Grid>

                                    </Grid>
                                </ControlTemplate>
                            </RadioButton.Template>
                        </RadioButton>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Border>
        
        <Image Grid.Row="1" Grid.Column="1" Source="{Binding MapImage}" Stretch="UniformToFill"/>

    </Grid>
</UserControl>
